/*
  Copyright (c) 2009 Dave Gamble

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
*/

#ifndef cJSON__h
#define cJSON__h

#define coreapi_CreateArray      0x0800cc28 +1
#define coreapi_CreateObject     0x0800cd74 +1
#define coreapi_CreateString     0x0800cd86 +1
#define coreapi_CreateNumber     0x0800cd50 +1  
#define coreapi_AddItemToArray   0x0800cbcc +1
#define coreapi_AddItemToObject  0x0800cbf8 +1
#define coreapi_JSON_Print       0x0800cfd4 +1
#define coreapi_JSON_Delete      0x0800cdf4 +1

/* The cJSON structure: */
typedef struct cJSON {
    struct cJSON *next,*prev;    /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
    struct cJSON *child;        /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */

    int type;                    /* The type of the item, as above. */

    char *valuestring;            /* The item's string, if type==cJSON_String */
    int valueint;                /* The item's number, if type==cJSON_Number */
    double valuedouble;            /* The item's number, if type==cJSON_Number */

    char *string;                /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
} cJSON;

#define cJSON_CreateArray(void)    		 				((cJSON* (*)(void))(coreapi_CreateArray))(void) 
#define cJSON_CreateObject(void)    		 			((cJSON* (*)(void))(coreapi_CreateObject))(void)  
#define cJSON_CreateString(arg)     					((cJSON* (*)(char *))(coreapi_CreateString))(arg)  
#define cJSON_CreateNumber(arg)     					((cJSON* (*)(double))(coreapi_CreateNumber))(arg)  
#define cJSON_AddItemToArray(array,object)    ((void (*)(cJSON *,cJSON *))(coreapi_AddItemToArray))(array,object)
#define cJSON_AddItemToObject(object,name,s)  ((void (*)(cJSON *,const char *,cJSON *))(coreapi_AddItemToObject))(object,name,s)
#define cJSON_Print(arg)           					  ((char * (*)(cJSON*))(coreapi_JSON_Print))(arg)
#define cJSON_Delete(arg)           					((void (*)(cJSON*))(coreapi_JSON_Delete))(arg)

#endif
